import 'dart:convert';
import 'package:ls_work/a_yyt/models/pending_entity.dart';

class MedicaServiceModel {
  final int? total;
  List<MedicaServiceInfo>? rows;

  MedicaServiceModel({this.rows, this.total});

  factory MedicaServiceModel.fromJson(Map<String, dynamic> json) {
    final originList = json['rows'] as List?;
    List<MedicaServiceInfo> protocolList =
        (originList??[]).map((value) => MedicaServiceInfo.fromJson(value)).toList();
    return MedicaServiceModel(rows: protocolList, total: json['total']);
  }
}

class MedicaServiceInfo {
  int? bizType;
  String? planStartTime;
  List<PendingInfo>? result;
  String? bizTypeName;
  int? id;
  String? property;
  String? expenseItem;
  String? resultUnit;

  String? itemRemark;
  DateTime? dateTime;
  bool? isSelected;
  int? expenseItemId;

  MedicaServiceInfo({
    this.bizType,
    this.planStartTime,
    this.result,
    this.bizTypeName,
    this.id,
    this.property,
    this.itemRemark,
    this.dateTime,
    this.expenseItem,
    this.isSelected,
    this.resultUnit,
    this.expenseItemId
    // this.confirmName,
  });

  factory MedicaServiceInfo.fromJson(Map<String, dynamic> json) {
    final List originList = jsonDecode(json['result']);
    List<PendingInfo> protocolList =
        originList.map((value) => PendingInfo.fromJson(value)).toList();
    return MedicaServiceInfo(
      result: protocolList,
      bizType: json['bizType'],
      planStartTime: json['planStartTime'],
      bizTypeName: json['bizTypeName'],
      id: json['id'],
      expenseItem: json["expenseItem"],
      itemRemark: "",
      dateTime: DateTime.now(),
      property: json['property'],
      resultUnit: json["resultUnit"],
      expenseItemId: json["expenseItemId"],
      isSelected: false,
    );
  }
}
